<?php

// Place in ./app/models/User.php

class User extends AppModel {
  var $name = "User";

  var $hasMany = array(
    "Feedfolder" => array(
      "className" => "Feedfolder"
    )/*,
		'Friend' => array(
		  'className' => 'Friend'	
		)*/
  );
	
	var $validate = array(
	  'username' => array(
		  'Please enter a username' => array(
				'rule' => 'notEmpty',
				'message' => 'Please enter a username'
			),
			'That username has already been taken' => array(
			  'rule' => 'isUnique',
				'message' => 'That username has already been taken'
			),
			'No spaces are allowed in usernames' => array(
				'rule' => 'noSpaces',
				'message' => 'No spaces are allowed in usernames'
			)
		),
		'email' => array(
		  'Please enter a valid e-mail address' => array(
				'rule' => 'validEmail',
				'message' => 'Please enter a valid e-mail address'
			)
		)
	);
	
	function noSpaces($data) {
		return !preg_match('/\s/', $data['username']);
	} // noSpaces()
	
	function validEmail($data) {
		return preg_match('/^[^@\s]+@[^@\s+]+$/', $data['email']);
	} // validEmail()
	
} // class User

?>